import { t } from 'i18next'
import { PollEntity } from '@/api/manager/poll/interface'
import { VmpEntity } from './interface'
export function transVmpDTO(data: VmpEntity) {
	return {
		id: data.id,
		name: data.name,
		layout: data.layout,
		mode: data.mode,
		except_self: data.except_self,
		voice_hint: data.voice_hint,
		broadcast: data.broadcast,
		show_mt_name: data.show_mt_name,
		mt_name_style: {
			font_color: data.mt_name_style?.font_color,
			font_size: data.mt_name_style?.font_size,
			position: data.mt_name_style?.position,
		},
		poll: data.poll ? transPoll(data.poll) : undefined,
		members: data.members
			? data.members.map((item) => ({
					chn_idx: item.chn_idx,
					member_type: item.member_type,
					name: item.name,
					account: item.account,
					account_type: item.account_type,
					mt_id: item.mt_id ? item.mt_id : item.mt_key,
					conf_e164: item.conf_e164,
					poll: item.poll ? transPoll(item.poll) : undefined,
			  }))
			: undefined,
	}
}
export function transPoll(data: PollEntity) {
	return {
		name: data.name,
		keep_time: data.keep_time,
		num: data.num,
		members: data.members.map((item) => ({
			account: item.account,
			account_type: item.account_type,
			name: item.name,
			mt_id: item.mt_id ? item.mt_id : item.mt_key,
			conf_e164: item.conf_e164,
		})),
	}
}
/**根据类型获取对应名称*/
export const getTvWallTypeName = (type: number) => {
	var _name = ''
	switch (type) {
		case 2:
			_name = t('发言方跟随')
			break
		case 3:
			_name = t('管理方跟随')
			break
		case 4:
			_name = t('会议轮询跟随')
			break
		case 10:
			_name = t('内容共享跟随')
			break
		case 6:
			_name = t('选看画面合成')
			break
		case 5:
			_name = t('单通道轮询')
			break
		case 8:
			_name = t('自主多画面')
			break
		case 9:
			_name = t('开启四分屏')
			break
		case 7:
			_name = t('批量轮询')
			break
		case 11:
			_name = t('会议广播跟随')
			break
	}
	return _name
}
/**错误码获取错误文本特指消息推送推送*/
export const handleGetEeeorCodeText = (errorCode?: number) => {
	let text = ''
	switch (errorCode) {
		case 28008:
			text = t('此通道不可用，请联系管理员')
			break
		case 28006:
			text = t('此通道异常，请联系管理员')
			break
		case 27504:
			text = t('此通道不支持四分屏')
			break
		case 28001:
			text = t('开启失败，终端能力超过该通道能力')
			break
		case 20444:
			text = t('开启失败，终端能力超过该通道能力')
			break
		case 28002:
			text = t('此通道被其他会议占用/其他会议正在使用此通道')
			break
		case 28004:
			text = t('此通道不支持四分屏')
			break
		case 21740:
			text = t('下级会议到上级会议的回传带宽不足')
			break
		case 20064:
			text = t('部分通道终端开启失败，请联系管理员')
			break
		case 20833:
			text = t('此通道与所选终端能力不匹配')
			break
		case 28015:
			text = t('该通道不支持此类型终端')
			break
		case 28018:
			text = t('此通道不支持四分屏')
			break
		case 20055:
			text = t('会议中未开启画面合成')
			break
		case 20517:
			text = t('所选终端视频画面异常，通道设置失败')
			break
		default:
			text = t('网络超时')
			break
	}
	return text
}
/**悬浮提示框内容*/
export const handleGetErrorTipText = (type: number) => {
	let text = ''
	switch (type) {
		case 1:
			text = t('HDU不在线!')
			break
		case 2:
			text = t('尚未配置任何电视墙通道，请联系管理员!')
			break
		case 3:
			text = t('其他会议正在使用此通道!')
			break
		case 4:
			text = t('网络超时!')
			break
		case 255:
			text = t('此通道不可用!')
			break
		default:
			text = ''
			break
	}
	return text
}
export const isEqualMtchnids = (arr: any, arr1: any) => {
	let flag = true
	for (let i = 0; i < arr.length; i++) {
		if (arr[i] != arr1[i] && arr[i] != null && arr1[i] != null) {
			flag = false
		}
	}
	return flag
}
